﻿using FreeAgent.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FreeAgent.ViewModels
{
    public class SearchResultsViewModel
    {
        public int id;
        public String type;
        public String name;
        public String email;
        public String phone;
        public String request;
        public String city;
        public String zipcode;
        public String handedness;
        public String request_date;

        public static IList<SearchResultsViewModel> searchResults(System.Collections.Specialized.NameValueCollection queryParams, List<String> Ordering = null, int? start = 0, int? limit = 20)
        {
            List<SearchResultsViewModel> results = new List<SearchResultsViewModel>();
            
            using (var ctx = new rsquaredFreeAgentEntities())
            {
                var q = (from ar in ctx.agent_requests
                         select new {
                             datetime_needed = ar.available_date,
                            ar.city
                         }).Union(
                         from tr in ctx.team_requests
                         select new {
                             tr.datetime_needed,
                             tr.city
                         });
                q.ToList();
            }
            //var query = (from
            //                free_agent_requests
            //             where
            //             select
 
            //            ).Union
            //            (from
            //                team_requests
            //             where
            //             select
            //            );

            return results;
        }
    }
}